import java.io.*;

public class user {
    //注册
    public  static  void  addstudent () throws IOException {
        resident sc =new resident();
        String sge,sid;
        BufferedReader buf =new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            System.out.println("请输入账号");
            sid=buf.readLine();
            if(sid.length()==6){
                break;
            }else { System.out.println("账号格式不对，请输入正确格式");}
        }
        String str;
        System.out.println("请输入密码");
        sge=buf.readLine();
        String str233;
        boolean a=true;
        str233="账号:"+sid+",密码:"+sge+"\n";
        BufferedWriter buf233=new BufferedWriter(new FileWriter("warehouse1.txt",a));
        BufferedReader in =new BufferedReader(new FileReader("warehouse1.txt"));
        while(( str=in.readLine())!=null){
            String syyy=str.substring(4,10);
            if((sid).equals(syyy)){
                System.out.println("账号重复，请重新输入");
                return;
            }
            else{}
            }
        in.close();
        buf233.write(str233);
        System.out.println("添加成功");
        buf233.close();
    }
    //登录
    public  static  void  denglu (int []age1) throws IOException {
        String str,sid,sge;
        BufferedReader buf =new BufferedReader(new InputStreamReader(System.in));
        System.out.println("请输入账号");
        sid=buf.readLine();
        BufferedReader in =new BufferedReader(new FileReader("warehouse1.txt"));
        System.out.println("请输入密码");
        sge= buf.readLine();
        while(( str=in.readLine())!=null){
            String syyy=str.substring(3,9);
            String srr=str.substring(13);
            if (sid.equalsIgnoreCase(syyy)){
            if((sid.equalsIgnoreCase(syyy))&&(sge.equals(srr))){
                age1[0]=11;
                System.out.println("登陆成功");
                break;
            }
            else{
                System.out.println("密码错误，请重新输入");
            }
            }
        }
    }
    public  static  void  denglu2 (int []age1) throws IOException {
        String sid1, sge1, sid, sge;
        sid1 = "123456";
        sge1 = "123456789";
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("请输入账号");
        sid = buf.readLine();
        System.out.println("请输入密码");
        sge = buf.readLine();
        if ((sid.equalsIgnoreCase(sid1)) && (sge.equals(sge1))) {
            System.out.println("登陆成功");
            age1[0] = 1111;
        } else {
            System.out.println("密码错误，请重新输入");
        }
    }
}


